
Ext.require([
    'Ext.form.*',
    'Ext.tip.QuickTipManager'
]);

Ext.onReady(function() {
    Ext.tip.QuickTipManager.init();

    var formPanel = Ext.widget('form', {
        renderTo: 'login_extjs',
        frame: true,
        width: 350,
        x: 100,
        y: 10,
        bodyPadding: 20,
        bodyBorder: true,
        title: 'INICIO DE SESION',

        defaults: {
            anchor: '100%'
        },

        items: [{
            xtype: 'textfield',
            name: 'login',
            fieldLabel: 'Usuario',
            allowBlank: false,
           
        }, {
            xtype: 'textfield',
            name: 'password',
            fieldLabel: 'Password',
            inputType: 'password',
            style: 'margin-top:10px',
            allowBlank: false,
           
        }],

        dockedItems: [{
            xtype: 'container',
            dock: 'bottom',
            layout: {
                type: 'hbox',
                align: 'middle'
            },
            padding: '5 0 5',

            items: [{
                xtype: 'button',
                formBind: true,
                disabled: true,
                text: 'LOGIN',
                width: 140,
                handler: function() {
                    var form = this.up('form').getForm();
                    form.submit({
                        url: '/login',	
                        success: function(form, action) {
			

                        },
                        failure: function(form, action) {
                            Ext.Msg.alert('LOGIN FALLIDO');
                        }		
						
                    });
                    if (form.isValid()) {
						Ext.MessageBox.show({
						   msg: 'Iniciando sesion ...',
						   width:300,
						   wait:true,
						   waitConfig: {interval:100},
						   
					   });
						setTimeout(function(){

							window.location = "main";
						}, 1000);
						
						
                    }
                    
                    
                }
            }]
        }]
    });
    



});

